package com.fullmail.adapter;

import java.util.List;

import com.fullmail.R;
import com.fullmail.bean.PersonBean;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class ContactListAdapter extends BaseAdapter{

	private List<PersonBean> list;
	private Context mContext;
	private LayoutInflater inflater;
	public ContactListAdapter(Context mContext, List<PersonBean> list) {
	
		this.mContext = mContext;
		this.list = list;

	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHolder holder = null;
		if (convertView == null) {
			inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			convertView = inflater.inflate(R.layout.items_person_list, null);
			holder = new ViewHolder();
			holder.ivHead=(ImageView)convertView.findViewById(R.id.iv_contact_head);
			holder.tvName=(TextView)convertView.findViewById(R.id.tv_contact_pb);
			holder.tvPhone=(TextView)convertView.findViewById(R.id.tv_contact_phone);
			convertView.setTag(holder);
		}else{
			holder = (ViewHolder) convertView.getTag();
		}
		holder.tvName.setText(list.get(position).getName());
		holder.tvPhone.setText(list.get(position).getPhone());
		return convertView;
	}
	class ViewHolder {
		ImageView ivHead;
		TextView tvName;
		TextView tvPhone;
	}
}
